
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[EBAS_SP_HENT_SENESTE_FEJL]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[EBAS_SP_HENT_SENESTE_FEJL]
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

CREATE PROCEDURE [DBO].[EBAS_SP_HENT_SENESTE_FEJL] 
	@brugerGuid varchar(255) = NULL
WITH ENCRYPTION
AS
	SET NOCOUNT ON

	IF @brugerGuid IS NULL
		SELECT * FROM EBAS_LOG
		WHERE OPRETTET_DATO = (
			SELECT MAX(OPRETTET_DATO)
			FROM EBAS_LOG )		
	ELSE
		SELECT * FROM EBAS_LOG
		WHERE OPRETTET_DATO = (
			SELECT MAX(OPRETTET_DATO)
			FROM EBAS_LOG )
		AND SIKKERHED_BRUGER_GUID = @brugerGuid
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO
